﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
                
>
  <xsl:output method="html" media-type="text/html" encoding="utf-8" />
  <xsl:param name="relrootpath"/>
  <xsl:template match="/ContactRequestContext">
    <xsl:variable name="ranum" select="generate-id(.)" />
   
    <Transform>

      <ContentToRender>
        <Template status="Pending">
          <Scripts>
            <Block name="scu-contactrequest">
              <script>
                function approvecontactrequest(requestid)
                {

                $.ajax({ type: 'POST',
                contentType: 'application/json',
                url: relRootPath + '/Mod/Contact/ContactWebService.asmx/ApproveContactRequest',
                data: "{ 'requestId': '" + requestid + "' }",
                dataType: 'json',
                async: true,
                success: function(result)
                {
                location.reload();
                },
                error: function(result, status) {
                $(this).attr('disabled', false);
                }
                }
                );

                }

                function rejectcontactrequest(requestid)
                {
                $.ajax({ type: 'POST',
                contentType: 'application/json',
                url: relRootPath + '/Mod/Contact/ContactWebService.asmx/RejectContactRequest',
                data: "{ 'requestId': '" + requestid + "' }",
                async: true,
                dataType: 'json',
                success: function(result)
                {
                location.reload();
                },
                error: function(result, status) {
                $(this).attr('disabled', false);
                }
                });
                }


                google.setOnLoadCallback(function()
                {
                $('.approvecontactbutton').click(function(){

                approvecontactrequest($(this).attr('rel'));
                disableactionbutton();
                });

                $('.rejectcontactbutton').click(function(){

                rejectcontactrequest($(this).attr('rel'));
                disableactionbutton();
                });
                });

                function disableactionbutton()
                {
                $('.actionbutton').attr('disabled', true).unbind('click');
                }


              </script>
            </Block>
          </Scripts>
          <Content>
            <div>
              <div>
                <control kind="userlink">
                  <xsl:attribute name="UserId">
                    <xsl:value-of select="RequestorUserId"/>
                  </xsl:attribute>
                </control>
                请求你加为好友。
              </div>
              <div class="ctn-p-t">
                "<xsl:value-of select="Comment"/>"
              </div>
              <div class="ctn-p-t">
                <a class="approvecontactbutton pointer actionbutton">
                  <xsl:attribute name="rel">
                    <xsl:value-of select="RequestId"/>
                  </xsl:attribute>
                  <xsl:text>同意请求</xsl:text>
                </a>
                |
                <a class="rejectcontactbutton pointer actionbutton">
                  <xsl:attribute name="rel">
                    <xsl:value-of select="RequestId"/>
                  </xsl:attribute>
                  拒绝请求
                </a>
              </div>
            </div>
          </Content>
        </Template>
        <Template status="Approved">
          <Content>
            <div>
              <strong>好友请求</strong>
              <div class="ctn-p-t">
                "<xsl:value-of select="Comment"/>"
              </div>
              <div class="r-app">
                  你已经同意了好友请求，快去看看
                  <control kind="userlink">
                <xsl:attribute name="UserId">
                  <xsl:value-of select="RequestorUserId"/>
                </xsl:attribute>
              </control>
                吧！
              </div>
            </div>
          </Content>
        </Template>
        <Template status="Rejected">
          <Content>
            <div>
              <strong>好友请求</strong>
              <div>
                "<xsl:value-of select="Comment"/>"
              </div>
              <div class="r-rej">
                你已拒绝了对方的请求。
              </div>
            </div>
          </Content>
        </Template>
      </ContentToRender>
      <ActionList>
        <Template status="Pending">
          <action webservicepath="" webmethod="" text="同意请求">
            <param name="requestid"></param>
          </action>
        </Template>
        <Template status="Rejected">

        </Template>
      </ActionList>
    </Transform>
  </xsl:template>
</xsl:stylesheet>
